package com.gewu.pm.ui.activity.filter.config;

import java.util.List;

/**
 * 筛选项配置类
 * 
 * 用于定义单个筛选项的所有配置信息，包括类型、标签、选项等
 * 
 * 工作流程：
 * 1. 通过 Builder 模式创建 FilterItem
 * 2. FilterConfig 收集所有 FilterItem
 * 3. FilterManager 根据 FilterItem 动态生成UI
 * 
 * 核心字段说明：
 * - type: 筛选类型（TEXT_SELECTOR、TAG_SELECTOR等）
 * - label: 显示的标签文字（如"销售区域"）
 * - hint: 未选择时的提示文字（如"请选择销售区域"）
 * - key: 数据的唯一标识，用于收集筛选结果
 * - selectorType: 文本选择器的类型（仅TEXT_SELECTOR使用）
 * - options: 选项列表（TAG_SELECTOR、MULTI_TAG_SELECTOR使用）
 * - columnCount: RecyclerView的列数（默认3列）
 * 
 * 使用示例：
 * FilterItem item = new FilterItem.Builder()
 *     .type(FilterType.TEXT_SELECTOR)
 *     .key("sales_area")
 *     .label("销售区域")
 *     .hint("请选择销售区域")
 *     .selectorType(SelectorType.SALES_REGION)
 *     .build();
 * 
 * @author AI Assistant
 * @since 1.0
 */
public final class FilterItem {
    
    /** 筛选类型（必填） */
    private final FilterType type;
    
    /** 显示标签（必填），如"销售区域"、"订单状态" */
    private final String label;
    
    /** 提示文字（可选），未选择时显示，如"请选择销售区域" */
    private final String hint;
    
    /** 选择器类型（TEXT_SELECTOR时必填） */
    private final SelectorType selectorType;
    
    /** 选项列表（TAG_SELECTOR、MULTI_TAG_SELECTOR时必填） */
    private final List<String> options;
    
    /** RecyclerView列数（默认3），用于TAG_SELECTOR、TIME_SELECTOR */
    private final int columnCount;
    
    /** 数据key（必填），用于收集筛选结果，如"sales_area" */
    private final String key;
    
    /** 是否支持多选（TEXT_SELECTOR时使用），默认false（单选） */
    private final boolean multiSelect;
    
    private FilterItem(Builder builder) {
        this.type = builder.type;
        this.label = builder.label;
        this.hint = builder.hint;
        this.selectorType = builder.selectorType;
        this.options = builder.options;
        this.columnCount = builder.columnCount;
        this.key = builder.key;
        this.multiSelect = builder.multiSelect;
    }
    
    public FilterType getType() {
        return type;
    }
    
    public String getLabel() {
        return label;
    }
    
    public String getHint() {
        return hint;
    }
    
    public SelectorType getSelectorType() {
        return selectorType;
    }
    
    public List<String> getOptions() {
        return options;
    }
    
    public int getColumnCount() {
        return columnCount;
    }
    
    public String getKey() {
        return key;
    }
    
    public boolean isMultiSelect() {
        return multiSelect;
    }
    
    public static final class Builder {
        private FilterType type;
        private String label;
        private String hint;
        private SelectorType selectorType;
        private List<String> options;
        private int columnCount = 3;
        private String key;
        private boolean multiSelect = false;
        
        public Builder type(FilterType type) {
            this.type = type;
            return this;
        }
        
        public Builder label(String label) {
            this.label = label;
            return this;
        }
        
        public Builder hint(String hint) {
            this.hint = hint;
            return this;
        }
        
        public Builder selectorType(SelectorType selectorType) {
            this.selectorType = selectorType;
            return this;
        }
        
        public Builder options(List<String> options) {
            this.options = options;
            return this;
        }
        
        public Builder columnCount(int columnCount) {
            this.columnCount = columnCount;
            return this;
        }
        
        public Builder key(String key) {
            this.key = key;
            return this;
        }
        
        public Builder multiSelect(boolean multiSelect) {
            this.multiSelect = multiSelect;
            return this;
        }
        
        public FilterItem build() {
            return new FilterItem(this);
        }
    }
}
